import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_widget_from_html_core/flutter_widget_from_html_core.dart';
import 'package:get/get.dart';
import 'package:x_common_utils/utils/inkWell_util.dart';
import 'package:xinxuan/common/scroll_configuration_common.dart';
import 'package:xinxuan/controllers/home_controller/home_page_controller.dart';
import 'package:xinxuan/utils/color_util.dart';

class NoticeDialog extends StatelessWidget {

  final HomePageController homePageController = Get.find();

  final String title;
  final String description;
  NoticeDialog({
    required this.title,
    required this.description,
  });

  @override
  Widget build(BuildContext context) {
    return Material(
      type: MaterialType.transparency,
      child: Center(
        child: Stack(
          children: [
            Container(
              width: 336.w,
              height: 417.h,
              alignment: Alignment.center,
              child: Container(
                width: 320.w,
                height: 417.h,
                child: Stack(
                  children: [
                    Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: <Widget>[
                        SizedBox(height: 92.h),
                        Container(
                          height: 324.h,
                          padding: EdgeInsets.only(left: 20.w, right: 20.w, bottom: 12.h),
                          decoration: BoxDecoration(
                            color: bgWhiteColor,
                            borderRadius: BorderRadius.circular(8.w)
                          ),
                          child: Column(
                            children: [
                              SizedBox(height: 87.h),
                              Container(
                                height: 46.h,
                                alignment: Alignment.center,
                                child: Text(
                                  '$title',
                                  maxLines: 1,
                                  overflow: TextOverflow.ellipsis,
                                  style: TextStyle(
                                    color: textBlackColor,
                                    fontSize: 16.sp,
                                    fontWeight: FontWeight.bold
                                  ),
                                )
                              ),
                              Expanded(child: ScrollConfigurationCommon(child: SingleChildScrollView(
                                child: HtmlWidget(
                                  '$description',
                                ),
                              ))),
                            ],
                          ),
                        )
                      ],
                    ),
                    Positioned(
                      top: 0,
                      child: Image.asset(
                        'assets/icons/icon_notice_bg.png',
                        width: 320.w,
                        height: 179.h,
                        fit: BoxFit.fill,
                      )
                    )
                  ],
                ),
              )
            ),
            Positioned(
              top: 76.h,
              right: 0,
              child: InkWellUtil.shakeProofInkWell(Image.asset(
                'assets/icons/icon_close_w.png',
                width: 30.w,
                height: 30.w,
              ), () {
                Get.back();
              },
              hoverColor: Colors.transparent,
              splashColor: Colors.transparent,
              highlightColor: Colors.transparent)
            )
          ],
        ),
      ),
    );
  }
}